import Vue from 'vue';
import App from './App.vue';
import ElementUI from  'element-ui';
import vueRouter from 'vue-router'
import Vuex from 'vuex'
import store from './vuex/store'
import login from './module/login/index';

import './element-variables.scss'
import 'element-ui/lib/theme-chalk/index.css';
import '../public/style/iconfont/iconfont.css';
import 'jquery';
import '../public/js/ht/ht.js';
import '../public/js/ht/ht-form.js';
import '../public/js/ht/ht-htmlnode.js';
import '../public/js/ht/ht-edgetype.js';
import '../public/js/ht/ht-autolayout.js';
import '../public/js/ht/ht-contextmenu.js';
import animated from 'animate.css'
Vue.use(animated)
// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
// const originalPush = vueRouter.prototype.push
// vueRouter.prototype.push = function push(location) {
//   return originalPush.call(this, location).catch(err => err)
// }
const routes = [
    // {path:'/', redirect: '/login'},
    {path:'/', redirect: '/connect'},
    {path:'/login', component: login},
    {path:'/', component: (resolve) => require(['./module/home'], resolve), children: [
        {path:'connect', component: (resolve) => require(['./module/connect/index'], resolve), children: [
                {path:'/', redirect: 'database'},
                {path:'database', component: (resolve) => require(['./module/connect/database/index'], resolve)},
                {path:'images', component: (resolve) => require(['./module/connect/image/index'], resolve), meta: {keepAlive: false}},
                {path:'imageDetail', component: (resolve) => require(['./module/connect/image/detail/index'], resolve), meta: {keepAlive: false}},
                {path:'unstructureFile', component: (resolve) => require(['./module/unstructureFile/index.vue'], resolve), meta: {keepAlive: false}}
            ]
        },
        {path:'model', component: (resolve) => require(['./module/model/index'], resolve), children: [
                {path:'/', redirect: 'alias'},
                {path:'alias', component: (resolve) => require(['./module/model/alias/index'], resolve)},
                {path:'source', component: (resolve) => require(['./module/model/source/index'], resolve)},
                {path:'transition', component: (resolve) => require(['./module/model/transition/index'], resolve)},
                {path:'regular_model', component: (resolve) => require(['./module/model/regular_model/index'], resolve)},
                {path:'grammar_model', component: (resolve) => require(['./module/model/grammar_model/index'], resolve)},
                {path:'training_model', component: (resolve) => require(['./module/model/training_model/index'], resolve)},
                {path:'log', component: (resolve) => require(['./module/model/log/index'], resolve)}
            ]
        },
        {path:'setting', component: (resolve) => require(['./module/block/index.vue'], resolve),
    }
    ]}
];

const router = new vueRouter({
    // mode: 'history',
    routes
});
// router.beforeEach((to, from, next) => {
//     if (!sessionStorage.token && to.path !== '/login') {
//         next({path: '/login'});
//     }
//     next();
// });


Vue.use(ElementUI);
Vue.use(vueRouter);
// Vue.use(ElementUI, {size: 'medium', zIndex: 3000});
Vue.use(Vuex);


Vue.config.productionTip = false;

new Vue({
    render: h => h(App),
    router,
    store
}).$mount('#app');